package com.bdqn.t350.proxy;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class IntermediaryMethodInterceptor implements MethodInterceptor {
    //Object o 被代理对象
    //Method method 被拦截方法
    //Object[] objects 被拦截方法参数
    //MethodProxy methodProxy  原始方法 sing()
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        before();
        Object message = methodProxy.invokeSuper(o, objects);
        after();
        return message;
    }

    public void before() {
        System.out.println("之前");
    }

    public void after() {
        System.out.println("之后");
    }
}
